I need to sequentially number test steps in a DOORS view. The numbers must be sequential starting from 1 at the top of the view. Ancestors of objects that meet the view's filter criteria must not be numbered. Objects not in the view must not be numbered. I tried layout DXL but it runs too many times for each object, thus the numbering does not end up being sequential. (e.g. 1, 4, 7...) I tried attribute DXL but it starts with whatever object is selected, not the first object in the view. I even tried forcing the current object to be the first object in the view, but the attribute DXL still treats the originally-selected object as its starting point. Any ideas? Here's my attribute DXL code as it stands:
Module m = current
current = first m //sets selected object to first in view
int number
//Condition to exclude objects not in current view.
//Also excludes ancestors of test step objects.
//Relies on module attribute MaxTestStepNumber to keep
//track of what the highest number is, currently.
//MaxTestStepNumber is also a DXL attribute that gets
//reset to zero every time DXL attributes are refreshed.
if ((isFiltered(obj)) && (obj."ObjectType" "" == "Test Step")) {
number = m."MaxTestStepNumber"
number++
//print obj."Absolute Number" "-" number "\n" //DEBUG
m."MaxTestStepNumber" = number
obj.attrDXLName = number ""
} else {
obj.attrDXLName = ""
}
Bob3 - Sat Mar 12 12:21:59 EST 2016 |
Re: Sequentially Number The Objects In a View But Not Ancestors when you say "starting from 1 at the top of the view", I assume that your filters are such that only the relevant test steps are shown. I also assume that it is irrelevant how the objects are indented. So, with a structure as given below, you want a numbering like the column "Calculated Number": (----update - IBM Developerworks seems to be broken again, cannot insert PNG picture here, so just try whether code helps----)
This can be accomplished with a layout DXL with the following code
Object o
int iNumber = 0
for o in current Module do {
iNumber++
if (o."Absolute Number" "" == obj."Absolute Number" "") {
display iNumber ""
}
}
The idea is: "for o in current Module" loops through all displayed objects and there's a counter iNumber that calculates the correct number for the current object (predefined variable "obj").
|
Re: Sequentially Number The Objects In a View But Not Ancestors Mike.Scharnow - Sun Mar 13 10:48:14 EDT 2016 when you say "starting from 1 at the top of the view", I assume that your filters are such that only the relevant test steps are shown. I also assume that it is irrelevant how the objects are indented. So, with a structure as given below, you want a numbering like the column "Calculated Number": (----update - IBM Developerworks seems to be broken again, cannot insert PNG picture here, so just try whether code helps----)
This can be accomplished with a layout DXL with the following code
Object o
int iNumber = 0
for o in current Module do {
iNumber++
if (o."Absolute Number" "" == obj."Absolute Number" "") {
display iNumber ""
}
}
The idea is: "for o in current Module" loops through all displayed objects and there's a counter iNumber that calculates the correct number for the current object (predefined variable "obj").
picture as attachment Attachments 2016-03-13 15_31_41-'ECU_Template_Level2' current 4.3 (Task .png |
Re: Sequentially Number The Objects In a View But Not Ancestors This is a novel approach, Mike. Thanks for your help! On each object, the script loops through all objects in the view, incrementing a counter for each object. When the script reaches the object that the layout DXL is actually running in right now, it displays the current count. This elegantly avoids the known behavior of layout DXL sometimes executing multiple times on a single object. Each object's numbering is absolute from the top of the view, rather than relative to a value that is incremented on each object for which the layout DXL executes. Two observations:
In my testing, a view with just over 100 numbered objects still maintained acceptable UI performance while running this layout DXL script. I am using DOORS 9.6.1 x64 on Windows 7 SP1 with a 4GHz eight core processor. With just one more condition, observation #2 can be easily dispatched. See line 4:
Object o
int iNumber = 0
for o in current Module do {
if (o."ObjectType" "" == "Design Statement") {
iNumber++
if (o."Absolute Number" "" == obj."Absolute Number" "") {
display iNumber ""
}
}
}
|
Re: Sequentially Number The Objects In a View But Not Ancestors Bob3 - Mon Mar 14 12:49:26 EDT 2016 This is a novel approach, Mike. Thanks for your help! On each object, the script loops through all objects in the view, incrementing a counter for each object. When the script reaches the object that the layout DXL is actually running in right now, it displays the current count. This elegantly avoids the known behavior of layout DXL sometimes executing multiple times on a single object. Each object's numbering is absolute from the top of the view, rather than relative to a value that is incremented on each object for which the layout DXL executes. Two observations:
In my testing, a view with just over 100 numbered objects still maintained acceptable UI performance while running this layout DXL script. I am using DOORS 9.6.1 x64 on Windows 7 SP1 with a 4GHz eight core processor. With just one more condition, observation #2 can be easily dispatched. See line 4:
Object o
int iNumber = 0
for o in current Module do {
if (o."ObjectType" "" == "Design Statement") {
iNumber++
if (o."Absolute Number" "" == obj."Absolute Number" "") {
display iNumber ""
}
}
}
I forgot one thing: when the number for current object has been found, it is of course not necessary to walk through the rest of the objects. So you will want to add a "break" statement after the "display" statement. This will make the script way faster for most of the objects.
With this addition, in a test with 4000 objects (9.6.1 x64, W10, 2,gGHz 4 core) while scrolling through the objects I saw a maximum calculation time of two seconds.
About your observation # 2: all depends on the quality your filter criteria. If you you display 2 "chapters" at the same time, you will probably want to add a condition to reset the counter to zero, perhaps if level (o) == 1 |